import re
import time

from bilibili import Bilibili

if __name__ == '__main__':
    while True:
        url = input('请输入要抓取的视频链接：')
        # 'https://www.bilibili.com/video/BV1jf4y1h73r/?spm_id_from=trigger_reload'
        # 'https://www.bilibili.com/bangumi/play/ep399420'
        reg = '^https://www\.bilibili\.com/\w+/\w+/?\w+'
        res = re.findall(reg, url, re.S)
        if res:
            url = res[0]
            break
        else:
            print('url有误，请重新输入，若要退出请输入：quit')

    start_time = time.time()

    bb = Bilibili(url)
    bb.main()
    print(bb.name + '--->共抓取' + str(bb.num) + '集')
    print(time.time() - start_time)
